package ar.edu.itba.it.pdc.configuration.models.filters.originFilters;

import java.net.InetAddress;
import java.util.SortedSet;

import ar.edu.itba.it.pdc.configuration.models.Request;

public class OriginIpGroupFilter extends OriginFilter{

	private SortedSet<InetAddress> ips;
	
	public OriginIpGroupFilter(SortedSet<InetAddress> ips) {
		this.ips = ips;
	}
	
	public boolean applyFilter(Request req) {
		return !ips.contains(req.getOriginIp());
	}
	
	@Override
	public String getContent() {
		
		String ans = "";
		
		int i = 1;
		for(InetAddress ip: ips) {
			ans = ans + ip.toString();
			if (i != ips.size()) {
				ans = ans + " | ";
			}
			i++;
		}
		return ans;
	}
	
	@Override
	public String getCriteria() {
		return "IP Group";
	}
}
